8 //p[x] == 0 si x es primo, sino p[x] == 1
11 //pot[i] contiene (a^(2^i))mod(n)
14 //f retorna (a^n)mod(n). Solo funciona si a,n < 65000!
15 //corre en orden O(log_2(n))
16 long long f(long long a
, long long n
){
23 bin
= (char)('0'+r
) + bin
;
27 for (int i
=1; i
<16; ++i
){
28 pot
[i
] = (pot
[i
-1]*pot
[i
-1]) % n
;
32 for (int i
=0; i
<bin
.size(); ++i
){
34 r
= (r
* pot
[bin
.size()-i
-1]) % n
;
42 for (int a
=2; a
<n
; ++a
){
43 //si no lo pasa return false
45 if (r
!= a
) return false;
52 for (int i
=2; i
<MAX
; i
++)
54 for (int j
=2*i
; j
<MAX
; j
+=i
)
59 while (scanf("%d", &n
) == 1 && n
> 0){
60 if (!p
[n
] || !c(n
)) printf("%d is normal.\n", n
);
62 printf("The number %d is a Carmichael number.\n", n
);